home *** CD-ROM | disk | FTP | other *** search
- /*
- * timer.c - Timer routines
- *
- * Copyright 1992-1993 Merit Network, Inc. and The Regents of the
- * University of Michigan. Usage of this source code is restricted
- * to non-profit, non-commercial purposes. The source is provided
- * "as-is", without warranty.
- */
- #include "ppp.h"
-
- void set_timer( struct TMtimer *t, struct fsm_s *fsm_p, voidProcPtr proc)
- {
- if (t->state == TIMER_RUN)
- RmvTime( (QElemPtr) t);
- t->proc = proc;
- t->fsm_p = fsm_p;
- t->duration = fsm_p->pdc.timeout * 1000L;
- t->state = TIMER_STOP;
- }
-
- void
- start_timer ( struct TMtimer *t )
- {
- short sreg;
-
- sreg = set_sr(0x2100); /* disable timer ints */
- if (t->atm.qType & TASK_QUEUED) {/* check if timer is primed */
- RmvTime( (QElemPtr) t);
- t->state = TIMER_STOP;
- }
- set_sr(sreg);
-
- if (t->state == TIMER_STOP) {
- bzero((b_8 *) t, (short) sizeof(TMTask)); /* clear tmtask struct */
- t->atm.tmAddr = (ProcPtr) t->proc;
- InsTime((QElemPtr) t);
- t->state = TIMER_RUN;
- }
- PrimeTime( (QElemPtr) t, t->duration);
- }
-
- void
- stop_timer ( struct TMtimer *t )
- {
- short sreg;
-
- sreg = set_sr(0x2100); /* Disable timer ints */
- if (t->state == TIMER_RUN) {
- RmvTime((QElemPtr) t);
- t->state = TIMER_STOP;
- }
- set_sr(sreg);
- }
-